package classrecord.classes.business;

public class ServiceRequestProcessor {
	
	private StudentCredentials studentCredentials;
	private int taskOriginator;
	
	/***** TASK ORIGINATORS *****/
	private final int TASK_ORIGINATOR_STUDENT_CREDENTIALS = 0;
	
	/***** TASK FLAGS *****/
	private final int TASK_FLAG_ADD = 0;
	private final int TASK_FLAG_UPDATE = 1;
	private final int TASK_FLAG_LOGICAL_DELETE = 2;
	private final int TASK_FLAG_PHYSICAL_DELETE = 3;
	private final int TASK_FLAG_LOGICAL_RETRIEVE = 4;
	private final int TASK_FLAG_PHYSICAL_RETRIEVE = 5;
	
	public void caterProcessOn(StudentCredentials studentCredentials) {
		this.studentCredentials = studentCredentials;
		this.taskOriginator = TASK_ORIGINATOR_STUDENT_CREDENTIALS;
	}
	
	public boolean process() {
		
		boolean wasProcessed = false;
		
		if (taskOriginator == TASK_ORIGINATOR_STUDENT_CREDENTIALS) {
			
			StudentCredentialsService studentCredentialsService = new StudentCredentialsService();
			studentCredentialsService.setStudentCredentials(studentCredentials);
			int taskFlag = studentCredentials.getTaskFlag();
			
			switch (taskFlag) {
			
			case TASK_FLAG_ADD:
				wasProcessed = studentCredentialsService.add();
				break;
				
			case TASK_FLAG_UPDATE:
				wasProcessed = studentCredentialsService.update();
				break;
			
			case TASK_FLAG_LOGICAL_DELETE:
				wasProcessed = studentCredentialsService.logicalDelete();
				break;
				
			case TASK_FLAG_PHYSICAL_DELETE:
				wasProcessed = studentCredentialsService.physicalDelete();
				break;
				
			case TASK_FLAG_LOGICAL_RETRIEVE:
				// wasProcessed = studentCredentialsService.logicalRetrieve();
				break;
				
			case TASK_FLAG_PHYSICAL_RETRIEVE:
				// wasProcessed = studentCredentialsService.physicalRetrieve()
				break;
				
			default:
				break;				
				
			}
			
			
			
		}
		
		return wasProcessed;
		
	}

}
